/*
 * TimeManager.h
 *
 *  Created on: 19.11.2012
 *      Author: Lapchinskiy
 */

#ifndef TIMEMANAGER_H_
#define TIMEMANAGER_H_
//#include "Scheduler.h"
#ifdef PC_DEBUG

#include "windows.h"
#include <time.h>
#include <process.h>
#include "Global_types.h"
#include "Scheduler.h"
#endif //PC_DEBUG
#ifdef PC_DEBUG
extern void TimerThreadCallback(void *args);
#endif //PC_DEBUG
class TimeManager {
private:
public:
	static int s_nValue;
	static uint32_t systemTime;
	static void SetSystemTime(uint32_t timeToset);
	volatile static bool enabled;
#ifdef PC_DEBUG
	static uint8_t threadStop;
#endif //PC_DEBUG
public:
	static ErrorCode Init(void) {
#ifdef PC_DEBUG
		_beginthread(TimerThreadCallback, 0, (void*) &TimeManager::threadStop);
#endif //PC_DEBUG
		return NO_ERR;
	}
	static uint32_t* GetSystemTime(void) {
		return &systemTime;
	}
	static void UpdateSystemTime(void);
//        {
//		if(enabled)
//		{
//			systemTime++;
//				if(*TimeManager::GetSystemTime()>=3000)
//				{
//					//Scheduler::stop();
//				}
//			Scheduler::sendEvent(SYS_TICK);
//		}
//
//	}

	static ErrorCode DeInit(void) {
#ifdef PC_DEBUG
		TimeManager::threadStop = TRUE;
#endif //PC_DEBUG
		return NO_ERR;
	}
};
#endif /* TIMEMANAGER_H_ */

